<template>
  <div class="app-container">
    <el-form :model="leaveFormData" ref="leaveFormData" >
            <el-row>
                <el-col :span="12">
                    <el-form-item label="请假开始时间" prop="leaveStartTime">
                        <el-date-picker
                            :disabled="true"
                            style="width:60%"
                            v-model="leaveFormData.leaveStartTime"
                            type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择开始日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="请假结束时间" prop="leaveEndTime">
                        <el-date-picker
                            :disabled="true"
                            style="width:60%"
                            v-model="leaveFormData.leaveEndTime"
                            type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择结束日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                
            </el-row>
            <el-row>
              <el-col :span="12">
                  <el-form-item label="请假总天数" prop="leaveTotalTime">
                      <el-input v-model="leaveFormData.leaveTotalTime" style="width:60%" :disabled="true"></el-input>
                  </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="初审部门" prop="approvedDept">
                      <el-cascader style="width: 81%;"  v-model="leaveFormData.approvedDeptModel" :disabled="true"
                        :options="deptOptions"
                        :props="props"
                        clearable></el-cascader>
                    </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="请假类型" prop="leaveType">
                <el-radio v-for="item in leaveTypeList" :key="item.id"  
                    v-model="leaveFormData.leaveType" :label="item.dictValue" :disabled="true">{{item.dictLabel}}</el-radio>
            </el-form-item>
            <el-form-item label="请假原因" prop="leaveRemarks">
                <el-input v-model="leaveFormData.leaveRemarks" type="textarea" style="width: 90%;" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="请假原因" prop="leaveRemarks">
                <el-input v-model="leaveFormData.leaveRemarks" type="textarea" style="width: 90%;" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="抄送人" prop="ccUsers">
                <el-tag v-for="item in leaveFormData.ccUserList" :key="item.id" style="margin-left: 3px;">{{item.userName}}</el-tag>
              </el-form-item>
            <el-row>
              <el-col :span="12">
                  <el-form-item label="申请人" prop="leaveTotalTime">
                      {{leaveFormData.createBy}}
                  </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="申请时间" prop="approvedDept">
                    {{parseTime(leaveFormData.createTime)}}
                    </el-form-item>
              </el-col>
            </el-row>
        </el-form>
  </div>
</template>

<script>
import { treeselectAll } from "@/api/system/dept";

export default {
  name: "leaveApplyDetail",
  props:{
    leaveFormData: Object,
    isShowLeave: Boolean
  },
  data() {
    return {
        leaveTypeList:[],
        props:{multiple: true},
        deptOptions:[]
    };
  },

  created() {
    this.getDicts("leave_type").then(response => {
      this.leaveTypeList = response.data;
    });
    this.getTreeselect()
    
  },
  methods: {
    handlePreview(file){
        this.preFile(file.url)
    },
    preFile(fileName){
      window.open(process.env.VUE_APP_BASE_API + "/school/file/" +fileName)
    },
    getTreeselect() {
        treeselectAll().then(response => {
            this.deptOptions = response.data;
        });
    },
    
  }
};
</script>
